const state = {
    contentItem: [],
    contentIndex: 0,
    picbookAudio: {},
    picbookType: "general"
}
const getters = {
    //获取content数组
    getContentItem(state) {
        return state.contentItem
    },
    //获取当前绘本页索引
    getContentIndex(state) {
        return state.contentIndex
    },
    //获取问题页数索引
    getQuestionIndex(state) {
        if (state.contentItem.length > 0 && state.picbookType !== 'poem') {
            return state.contentItem[state.contentIndex].id
        } else {
            return state.contentIndex
        }
    },
    //绘本类型
    getPicbookType(state) {
        return state.picbookType
    },
    //绘本音效
    getPicbookAudio(state) {
        return state.picbookAudio
    }
};
const mutations = {
    //初始化content数组 绘本页索引 计时
    setContentItem(state, param) {
        state.contentItem = param
        state.contentIndex = 0
        state.time = 0
    },
    //初始化绘本类型
    setPicbookType(state, param) {
        state.picbookType = param
    },
    //更新旁白时间
    updateTime(state, param) {
        state.time = param === 0 ? 0 : state.time + param
    },
    //更新绘本页索引
    updateContentIndex(state, param) {
        state.contentIndex = param
    },
    //初始化绘本音效
    setPicbookAudio(state, param) {
        state.picbookAudio = param
    }
};
const actions = {
    setContentItem({ commit }, param) {
        commit('setContentItem', param);
    },
    setPicbookType({ commit }, param) {
        commit('setPicbookType', param)
    },
    updateContentIndex({ commit }, param) {
        commit("updateContentIndex", param)
    },
    updateTime({ commit }, param) {
        commit("updateTime", param)
    },
    setPicbookAudio({ commit }, param) {
        commit("setPicbookAudio", param)
    }
};
export default {
    namespaced: true,//用于在全局引用此文件里的方法时标识这一个的文件名
    state,
    getters,
    mutations,
    actions
}
